# Contributor: Lauren N. Liberda <lauren@selfisekai.rocks>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=minizip-ng
pkgver=4.0.4
pkgrel=0
pkgdesc="zlib-ng fork of minizip"
url="https://github.com/zlib-ng/minizip-ng"
arch="all"
license="Zlib"
makedepends="
	bzip2-dev
	cmake
	gtest-dev
	ninja
	openssl-dev
	python3
	xz-dev
	zstd-dev
	zlib-ng-dev
	"
subpackages="$pkgname-dev"
source="
	https://github.com/zlib-ng/minizip-ng/archive/refs/tags/$pkgver/minizip-ng-$pkgver.tar.gz
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DMZ_BUILD_TESTS=ON \
		-DMZ_BUILD_UNIT_TESTS=ON \
		-DMZ_COMPAT=ON \
		-DMZ_FETCH_LIBS=OFF \
		-DMZ_LIB_SUFFIX=-ng \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest -j1
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2662ddf90666babe73474f6fc48f5a64f276d555b7a0f04f790b9edef570cb958356e900632c3795fb2053f4813c449240ff101d32b063eca4ad869bef0546fd  minizip-ng-4.0.4.tar.gz
"
